#include "data_types.h"

const QString kResult("result");
const QString kCurrentPage("current_page");
const QString kTotalPages("total_pages");
const QString kTotalEntries("total_entries");
const QString kActivities("activities");
const QString kActivity("activity");
const QString kId("id");
const QString kUserId("user_id");
const QString kRecommendUser("recommend_user");
const QString kOrganizerId("organizer_id");
const QString kCalendarId("calendar_id");
const QString kName("name");
const QString kEnglishName("english_name");
const QString kLocation("location");
const QString kAddress("address");
const QString kEnglishAddress("english_address");
const QString kCategory("category");
const QString kSubCate("subcate");
const QString kTags("tags");
const QString kLat("lat");
const QString kLng("lng");
const QString kMatchLevel("match_level");
const QString kShowImageUrl("show_image_url");
const QString kThumbImageUrl("thumb_image_url");
const QString kViewCount("view_count");
const QString kCommentCount("comment_count");
const QString kRecommendCount("recommend_count");
const QString kCheckinCount("checkin_count");
const QString kSubscribeCount("subscribe_count");
const QString kRank("rank");
const QString kAccessType("access_type");
const QString kIsAuth("is_auth");
const QString kIsLong("is_long");
const QString kIsPast("is_past");
const QString kIsMovie("is_movie");
const QString kStartTime("start_time");
const QString kEndTime("end_time");
const QString kCreatedOn("created_on");
const QString kBody("body");
const QString kDescription("description");

int parse_activity(QDomElement &e, activity &a) {
  QDomNodeList list = e.childNodes();
  for (int i = 0; i < list.count(); ++i) {
    QDomElement n = list.at(i).toElement();
    if (n.nodeName() == kId) {
      a.id = n.text().toInt();
    }
    if (n.nodeName() == kUserId) {
      a.user_id = n.text().toInt();
    }
    if (n.nodeName() == kRecommendUser) {
      a.recommend_user = n.text().toInt();
    }
    if (n.nodeName() == kOrganizerId) {
      a.organizer_id = n.text().toInt();
    }
    if (n.nodeName() == kCalendarId) {
      a.calendar_id = n.text().toInt();
    }
    if (n.nodeName() == kName) {
      a.name = n.text();
    }
    if (n.nodeName() == kEnglishName) {
      a.english_name = n.text();
    }
    if (n.nodeName() == kLocation) {
      a.location = n.text();
    }
    if (n.nodeName() == kAddress) {
      a.address = n.text();
    }
    if (n.nodeName() == kEnglishAddress) {
      a.english_address = n.text();
    }
    if (n.nodeName() == kCategory) {
      a.category = n.text();
    }
    if (n.nodeName() == kSubCate) {
      a.subcate = n.text();
    }
    if (n.nodeName() == kTags) {
      a.tags = n.text();
    }
    if (n.nodeName() == kLat) {
      a.lat = n.text().toInt();
    }
    if (n.nodeName() == kLng) {
      a.lng = n.text().toInt();
    }
    if (n.nodeName() == kMatchLevel) {
      a.match_level = n.text();
    }
    if (n.nodeName() == kShowImageUrl) {
      a.show_image_url = n.text();
    }
    if (n.nodeName() == kThumbImageUrl) {
      a.thumb_image_url = n.text();
    }
    if (n.nodeName() == kViewCount) {
      a.view_count = n.text().toInt();
    }
    if (n.nodeName() == kCommentCount) {
      a.comment_count = n.text().toInt();
    }
    if (n.nodeName() == kRecommendCount) {
      a.recommend_count = n.text().toInt();
    }
    if (n.nodeName() == kCheckinCount) {
      a.checkin_count = n.text().toInt();
    }
    if (n.nodeName() == kSubscribeCount) {
      a.subscribe_count = n.text().toInt();
    }
    if (n.nodeName() == kRank) {
      a.rank = n.text().toInt();
    }
    if (n.nodeName() == kAccessType) {
      a.access_type = n.text();
    }
    if (n.nodeName() == kIsAuth) {
      a.is_auth = n.text().toInt();
    }
    if (n.nodeName() == kIsLong) {
      a.is_long = n.text().toInt();
    }
    if (n.nodeName() == kIsPast) {
      a.is_past = n.text().toInt();
    }
    if (n.nodeName() == kIsMovie) {
      a.is_movie = n.text().toInt();
    }
    if (n.nodeName() == kStartTime) {
      a.start_time = n.text();
    }
    if (n.nodeName() == kEndTime) {
      a.end_time = n.text();
    }
    if (n.nodeName() == kCreatedOn) {
      a.created_on = n.text();
    }
    if (n.nodeName() == kBody) {
      a.body = n.text();
    }
    if (n.nodeName() == kDescription) {
      a.description = n.text();
    }
  }

  return 0;
}
